1 19:09:14
<template id="table1">
  <div>
    <table border="1">
      <tr>
        <th>编号</th>
        <th>纸质</th>
        <th>操作</th>
      </tr>

      <tr v-for="item in list">
        <td>{{item.id}}</td>
        <td>{{item.name}}</td>
        <td> <button @click="del(item.id)">删除</button>/
          <button @click="update(item)">修改</button></td>
      </tr>
    </table>
    <div>
      <form>
        纸张: <input v-model="texture.name"/><br>
        <button type="submit" @click="add()">提交</button>
      </form>
    </div>
    <div>
      <form>
        id:<input  v-model="texture1.id" /><br>
        纸张: <input  v-model="texture1.name"/><br>
        <button type="submit" @click="upd()">提交</button>
      </form>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import qs from 'qs'
export default {
  name: 'TextureManager',
  data () {

    return {
      texture1:{id:"",name:""},
      texture:{name:""},
      list: []
    }
  },
  components:{
    "table1":{
      template:"table1",
      props:{
        list:[],
        title:""
      }
    }
  },
  created() {
    this.$http.post('/texture/select').then(data=>{
      this.list = data;
    })
  },
  methods:{
    del(id){
      alert(id);
      // var params = new URLSearchParams();
      // params.append('id', '70');
      // var f = new FormData()
      // f.append('id', id)
      this.texture.id=id;
      this.$http.post("/texture/delete",this.texture);
      //$.post("http://localhost:8080/texture/select");
      window.location.reload();
    },
    add(){
      //alert("11");
      // var f = new FormData()
      // f.append('name',this.texture.name)
      this.$http.post("/texture/insert", this.texture).then(add=>{
        alert(add);
        if(add>0){
          alert("添加成功");
          window.location.reload();
        }else{
          alert("添加失败")
        }
      })
    },
    update(item){
      this.texture1=item.id;
      this.texture1.name=item.name
     // this.texture.name=item.name;
    },
    upd(){
      // alert("33");
      // alert(item);
      // this.texture.id=item.id;
      // this.texture.name=item.name;
      this.$http.post("/texture/update",this.texture).then(add=>{
        //alert(add);
        if(add>0){
          alert("修改成功");
          window.location.reload();
        }else{
          alert("修改失败")
        }
      });
    }
  }
}
</script>

<style scoped>

</style>

